<html>
<head><meta charset="utf-8"><title>Path resolution does not like assoc items · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html">Path resolution does not like assoc items</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247193668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247193668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247193668">(Jul 26 2021 at 12:11)</a>:</h4>
<p>Our current path resolution implementation doesn't actually resolve associated items at all(NameRefClass avoids this with all its extra prior checks). This gives us problems with intra doc link resolution currently though as all of those fail. Is this intentional and just requires workaround for doc link resolution or is this something that path resolution should actually resolve</p>



<a name="247193694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247193694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247193694">(Jul 26 2021 at 12:11)</a>:</h4>
<p>Example here: <br>
<a href="/user_uploads/4715/cvidxkoFOrs2VO36B4iZTVoi/image.png">image.png</a> <br>
All of these links do not resolve as path resolution only resolves the <code>Struct</code> prefix giving up afterwards</p>
<div class="message_inline_image"><a href="/user_uploads/4715/cvidxkoFOrs2VO36B4iZTVoi/image.png" title="image.png"><img src="/user_uploads/4715/cvidxkoFOrs2VO36B4iZTVoi/image.png"></a></div>



<a name="247193847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247193847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247193847">(Jul 26 2021 at 12:14)</a>:</h4>
<p>Which aspect of Path resolution? The one in semantics shoudl resovle everything. THe one in nameres doesn't know about asoc items</p>



<a name="247193848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247193848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247193848">(Jul 26 2021 at 12:14)</a>:</h4>
<p>Ah wait, this is technically a problem with calling <code>resolve_module_path_in_items</code> I suppose</p>



<a name="247193923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247193923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247193923">(Jul 26 2021 at 12:14)</a>:</h4>
<p>Ye I was looking at the wrong parts I believe, still quite a bit in the dark when it comes to RA's path res <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="247193931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247193931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247193931">(Jul 26 2021 at 12:14)</a>:</h4>
<p>Basically, stuff which takes a specific <code>ast::Path</code> can do this, things working on <code>hir::Path</code> can't</p>



<a name="247194005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247194005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247194005">(Jul 26 2021 at 12:15)</a>:</h4>
<p>Basically we currently create a resolver for the item whose docs we are inspecting and resolving the path via <code>resolve_module_path_in_items</code> on said item which fails in this case.</p>



<a name="247194082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247194082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247194082">(Jul 26 2021 at 12:16)</a>:</h4>
<p>Because it only resolves to the struct at which point it bails out as there are segments left, so I guess calling <code>resolve_module_path_in_items</code> isnt the right call here?</p>



<a name="247194110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247194110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247194110">(Jul 26 2021 at 12:17)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir/src/attrs.rs#L145-L148">https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir/src/attrs.rs#L145-L148</a></p>



<a name="247194297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247194297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247194297">(Jul 26 2021 at 12:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133169">matklad</span> <a href="#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items/near/247193931">said</a>:</p>
<blockquote>
<p>Basically, stuff which takes a specific <code>ast::Path</code> can do this, things working on <code>hir::Path</code> can't</p>
</blockquote>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="247195362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247195362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247195362">(Jul 26 2021 at 12:33)</a>:</h4>
<p>(deleted)</p>



<a name="247197632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247197632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247197632">(Jul 26 2021 at 12:55)</a>:</h4>
<p>Hmm this is gonna be ugly I feel like. So everything that currently works on the hir for this pretty much has to go back to the AST I think <span aria-label="confused" class="emoji emoji-1f615" role="img" title="confused">:confused:</span><br>
As in all of the <code>doc_links</code> module will work on the ast and not the hir, actually maybe not since one can go from hir to ast. Will have to check again</p>



<a name="247198065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198065">(Jul 26 2021 at 12:58)</a>:</h4>
<p>Yeah, that's tricky....</p>
<p>The thing is, our hir lacks identity semantics -- you can't look at a <code>hir::Path</code> and say where did it originated from. And you need that for assoc items, as they, in general, depend on types&amp;bodies.</p>



<a name="247198308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198308">(Jul 26 2021 at 13:00)</a>:</h4>
<p>that's what we have <code>SemanticsScope</code> for though, isn't it?</p>



<a name="247198430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198430">(Jul 26 2021 at 13:01)</a>:</h4>
<p>Ye my main problem was how to get one from a <code>Definition</code> but that shouldn't be a problem actually</p>



<a name="247198451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198451">(Jul 26 2021 at 13:01)</a>:</h4>
<p>Although, I am wondering if we are talking about the right thing here...</p>



<a name="247198558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198558">(Jul 26 2021 at 13:02)</a>:</h4>
<p>As I see it, doc link resolving is a rather special case, it <em>should</em> be handled by the <code>HasAttrs::resolev_doc_path</code> function</p>



<a name="247198642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198642">(Jul 26 2021 at 13:03)</a>:</h4>
<p>And that is inside <code>hir</code> already, ie, it doesn't have ast, Definition or Semantics</p>



<a name="247198817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198817">(Jul 26 2021 at 13:04)</a>:</h4>
<p>Well it already special cases resolution for assoc trait items in there</p>



<a name="247198843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198843">(Jul 26 2021 at 13:04)</a>:</h4>
<p>But that approach doesn't work for impl assoc items</p>



<a name="247198931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198931">(Jul 26 2021 at 13:05)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/resolver.rs#L147-L171">https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/resolver.rs#L147-L171</a></p>



<a name="247198957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247198957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247198957">(Jul 26 2021 at 13:05)</a>:</h4>
<p>Yeah, looking at it. Seems that that doesn't work exactly as it should</p>



<a name="247199009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247199009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247199009">(Jul 26 2021 at 13:06)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/blob/35e072ed44c55e5c74640fe7ab3aeffe20306d2a/crates/hir_def/src/resolver.rs#L83">https://github.com/rust-analyzer/rust-analyzer/blob/35e072ed44c55e5c74640fe7ab3aeffe20306d2a/crates/hir_def/src/resolver.rs#L83</a></p>



<a name="247199109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247199109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247199109">(Jul 26 2021 at 13:07)</a>:</h4>
<p>This think should be used, but I am not seeing it there. This <code>Partial</code> variant says:</p>
<p>"hey, I've resolevd up to <code>idx</code> segments out of the original path, and the result is this <code>Ty</code>. Resolve the rest using associcated items machinery"</p>



<a name="247199480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247199480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247199480">(Jul 26 2021 at 13:10)</a>:</h4>
<p>Isn't that only for values though?</p>



<a name="247199558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247199558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247199558">(Jul 26 2021 at 13:11)</a>:</h4>
<p>I think it is, but seems like a similar thing should be done for types?</p>



<a name="247199588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247199588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247199588">(Jul 26 2021 at 13:11)</a>:</h4>
<p>Alright, I'll look into that then.</p>



<a name="247199673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247199673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247199673">(Jul 26 2021 at 13:12)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">resolve_path_in_type_ns</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">db</span>: <span class="kp">&amp;</span><span class="nc">dyn</span><span class="w"> </span><span class="n">DefDatabase</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">path</span>: <span class="kp">&amp;</span><span class="nc">ModPath</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Option</span><span class="o">&lt;</span><span class="p">(</span><span class="n">TypeNs</span><span class="p">,</span><span class="w"> </span><span class="nb">Option</span><span class="o">&lt;</span><span class="kt">usize</span><span class="o">&gt;</span><span class="p">)</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
</code></pre></div>
<p>I guess someone was inconsistently lazy with respect to extracting named types</p>



<a name="247200363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247200363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247200363">(Jul 26 2021 at 13:18)</a>:</h4>
<p>well, I guess it was necessary to create an enum for one, and not strictly necessary for the other ;)</p>



<a name="247200445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247200445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247200445">(Jul 26 2021 at 13:18)</a>:</h4>
<p>actually resolving the associated items might require extracting some of the code for that from type inference</p>



<a name="247200449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247200449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247200449">(Jul 26 2021 at 13:18)</a>:</h4>
<p>which would be good anyway</p>



<a name="247200922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247200922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247200922">(Jul 26 2021 at 13:22)</a>:</h4>
<p>Right inference already has to do that as well doesnt it</p>



<a name="247202258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247202258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247202258">(Jul 26 2021 at 13:31)</a>:</h4>
<p>mostly I think the relevant code is in <code>infer/path.rs</code></p>



<a name="247202526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247202526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247202526">(Jul 26 2021 at 13:32)</a>:</h4>
<p>and it mostly doesn't interact much with the rest of inference, I think, so it maybe actually won't be that hard to extract... I think <span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<a name="247202559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247202559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247202559">(Jul 26 2021 at 13:33)</a>:</h4>
<p>Well, we'll see <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="247202576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247202576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247202576">(Jul 26 2021 at 13:33)</a>:</h4>
<p>except for writing results in the end</p>



<a name="247235986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247235986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247235986">(Jul 26 2021 at 17:40)</a>:</h4>
<p>Seems like it calls quite a bit into the <code>InferenceTable</code> which makes this pretty difficult to extract</p>



<a name="247240837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247240837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247240837">(Jul 26 2021 at 18:15)</a>:</h4>
<p>does it? I only see three direct uses of the inference table, one is just getting the trait env, and the other two are at the end (the part that should not be extracted)</p>



<a name="247241015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247241015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247241015">(Jul 26 2021 at 18:16)</a>:</h4>
<p>so for example for <code>resolve_ty_assoc_item</code>, I'd probably expect the extracted version to return the <code>AssocItemId</code></p>



<a name="247245088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Path%20resolution%20does%20not%20like%20assoc%20items/near/247245088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Path.20resolution.20does.20not.20like.20assoc.20items.html#247245088">(Jul 26 2021 at 18:48)</a>:</h4>
<blockquote>
<p>well, I guess it was necessary to create an enum for one, and not strictly necessary for the other </p>
</blockquote>
<p>Hm, it seems to me that we do want to extract <code>(TypeNs, usize)</code> pair into a struct  in both cases, as that has a clear meaning of "partially resovled assoc type"</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>